package org.tinycloud.tinyjob.client.interceptor;

import java.util.Objects;

public class JobSubjectHolder {
    private final static ThreadLocal<JobSubject> cache = new ThreadLocal<>();

    public static JobSubject getJobSubject() {
        JobSubject subject = cache.get();
        if (Objects.isNull(subject)) {
            return null;
        } else {
            return subject;
        }
    }

    public static void setJobSubject(JobSubject JobSubject) {
        cache.set(JobSubject);
    }

    public static void clear() {
        cache.remove();
    }
}
